package com.sky.controller.user;

import com.sky.entity.Setmeal;
import com.sky.result.Result;
import com.sky.service.SetMealService;
import com.sky.vo.DishItemVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.License;
import io.swagger.models.auth.In;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController("userSetmealController")
@Slf4j
@Api(tags = "套餐相关接口")
@RequestMapping("/user/setmeal")
public class SetmealController {


    @Autowired
    private SetMealService service;


   @GetMapping("/list")
   @ApiOperation("根据类别id获取套餐列表")
   @Cacheable(cacheNames = "setmeal",key = "#categoryId")
   public Result<List<Setmeal>> getSetmealList(Long categoryId){
        List<Setmeal> setmealList= service.getList(categoryId);
        return Result.success(setmealList);
   }

   @GetMapping("/dish/{id}")
   @ApiOperation("根据菜品id获取菜品口味列表")
   public Result<List<DishItemVO>> getSetmealDish(@PathVariable Long id){

       return Result.success(service.getSetmealDishItem(id));
   }



}
